<?
session_start();
include("gestione/includes/config.inc.php");
include("gestione/includes/auth.lib.php");
include("gestione/includes/function.inc.php");
include("gestione/includes/genpass.class.php");
include("gestione/includes/product_new.class.php");
include("gestione/includes/e-commerce_new.class.php");
include("gestione/includes/news.class.php");
include("gestione/includes/content.class.php");
include("gestione/includes/keywords.class.php");
include("gestione/includes/class.xml.php");
include("gestione/includes/newsletter.class.php");
$lang = "ita";
$adminmail = "info@bsvillage.com";
//$adminmail = "max@media-tek.it";
####################### TOYS #######################################################
$cid = 689;
$tiponews = "toys";
####################### SESSION ##############################################################
$newSession = new websession();
$strNumArt = '<span class="ajax_cart_no_product">(vuoto)</span>';
$str_tot = 0;
if($newSession->order != NULL) {
	$articoli = $newSession->order->getArticoli();
	$numArt = count($articoli);
	$tot = $newSession->order->getTotale($articoli);
	$tot=="" ? $str_tot = 0 : $str_tot = number_format($tot,2,",",".");
	if($numArt>0) {
		$numArt>1 ?
		$strNumArt = '<span class="ajax_cart_quantity">'.$numArt.'</span> <span class="ajax_cart_product_txt">prodotti</span>' : 
		$strNumArt = '<span class="ajax_cart_quantity">'.$numArt.'</span> <span class="ajax_cart_product_txt">prodotto</span>';
	} else 
		$strNumArt = '<span class="ajax_cart_no_product">(vuoto)</span>';
}
if($newSession->getStatus())  {
	$registrati = '<li id="your_account"><a href="/webproduct.php?op=profile" title="Il tuo Profilo">Il tuo Profilo</a></li>
	<li id="header_user_info">
		Welcome '.$newSession->webuser->ragione.',
					(&nbsp;<a href="/webproduct.php?op=logout">Log out</a>&nbsp;)
			</li>';
	$tablelogin = '';
} else {
	$registrati = '<li id="your_account">&nbsp;</li>
	<li id="header_user_info">
		Welcome,
					(&nbsp;<a href="/webproduct.php?op=register">Login</a>&nbsp;)
			</li>';
}
####################################################################################################
$op = $_GET['op'];
if($op == "")
$op = $_POST['op'];
switch($op) {
	
	case "check_captcha":
		if (strtoupper($_POST['captcha']) == strtoupper($_SESSION['cod_captcha'])) {
			$_SESSION['cod_captcha'] = '';
			die('{"success":true}');
		} else
		die('{"success":false}');
		break;

	case "register":
		//utente non loggato che fa acquisti e vuole pagare
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Registrazione / Accesso</div>';
		$mode = $_GET['mode'];
		$content = '<h1>Registrazione / Accesso</h1>';
		 
		if($mode=="cart")
		$content.= '<div class="navbar-cart"><img src="/images/01-grigio.jpg"><img src="/images/02-blu.jpg"><img src="/images/03-grigio.jpg"></div><br><br>';
		$content .= '<p>Come utente registrato di <b>youtoys.it</b> puoi completare pi&ugrave; velocemente la procedura d\'ordine, richiamando le informazioni della tua scheda personale. Inserisci nei due campi qui sotto l\'username con il quale ti sei registrato e la password scelta in quel momento.</p>
		   <form action=webproduct.php method=POST>
		   <fieldset>
		    <p class="text">
			 <label for="username">username:</label>
			 <input type=text name=username size=30>
			</p>
		    <p class="text">
			 <label for="password">password:</label>
			 <input type=password name=password size=30>
			</p>
		    <p class="submit">
			 <input type=hidden name=op value=login>
			 <input class="button" type="submit" value="Login">
			</p>
			</fieldset>
		   </form>
		   <p>&nbsp;</p>
			  <p>
			    <b>Hai scordato la password?</b>&nbsp;<a class=plain href="webproduct.php?op=risend_password"><b>Clicca qui</b></a>.
				</p>
				<p>&nbsp;</p>
		<form name="subscribe" action="webproduct.php" method="POST" class="std">
		<fieldset class="account_creation">
		<h3>Non sei Utente Registrato? Inserisci i dati per completare l\'acquisto</h3>
		<p>( * campi obbligatori)</p>
		<p class="required text">
		<label for="nome">Nome:</label>
		<input type="text" name="nome" size=30 value="'.($_SESSION['nome']!="" ? $_SESSION['nome'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="cognome">Cognome o Ragione Sociale:</label>
		<input type="text" name="cognome" size=30 value="'.($_SESSION['cognome']!="" ? $_SESSION['cognome'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="username">Username:</label>
		<input type="text" name="ragione" size=30 value="'.($_SESSION['ragione']!="" ? $_SESSION['ragione'] : '').'" /><sup>*</sup>
		</p>
		<p class="text">
		<label for="username">Data di nascita:</label>
		<input type=text size=10 name=data_nascita id=data onBlur="check_date(this)" value="gg/mm/aaaa">
		</p>
		<p class="text">
		<label for="cf">Codice fiscale(da indicare SEMPRE,anche se uguale a Partita IVA):</label>
		<input type="text" name="cf" size="30" value="'.($_SESSION['cf']!="" ? $_SESSION['cf'] : '').'" />
		</p>
		<p class="text">
		<label for="pi">Partita iva:</label>
		<input type="text" name="pi" size="30" value="'.($_SESSION['pi']!="" ? $_SESSION['pi'] : '').'" />
		</p>
		<p class="required text">
		<label for="indirizzo">Indirizzo:</label>
		<input type="text" name="indirizzo" size="30" value="'.($_SESSION['indirizzo']!="" ? $_SESSION['indirizzo'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="localita">Localit&aacute;:</label>
		<input type="text" name="localita" size="30" value="'.($_SESSION['localita']!="" ? $_SESSION['localita'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="cap">CAP:</label>
		<input type="text" name="cap" size="30" value="'.($_SESSION['cap']!="" ? $_SESSION['cap'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="provincia">Provincia:</label>';
		//select provincia
		$sql = "SELECT provincia,sigla FROM province ORDER BY provincia;";
		$rsmenu = $conn->Execute($sql);
		$content .= $rsmenu->GetMenu("provincia",$_SESSION['provincia'],false);
		$rsmenu->Close();
		$content .= '<sup>*</sup>
		</p>
		<p class="required text">
		<label for="nazione">Nazione:</label>';
		//select provincia
		$sql = "SELECT valore,id FROM nazioni ORDER BY valore;";
		$rsmenu = $conn->Execute($sql);
		$content .= $rsmenu->GetMenu("nazione",'Italy',false);
		$rsmenu->Close();
		$content .= '<sup>*</sup>
		</p>
		<p class="required text">
		<label for="telefono">Telefono:</label>
		<input type="text" name="telefono" size="30" value="'.($_SESSION['telefono']!="" ? $_SESSION['telefono'] : '').'" /><sup>*</sup>
		</p>
		<p class="text">
		<label for="cellulare">Telefono cellulare:</label>
		<input type="text" name="cellulare" size="30" value="'.($_SESSION['cellulare']!="" ? $_SESSION['cellulare'] : '').'" />
		</p>
		<p class="required text">
		<label for="mail">E-mail:</label>
		<input type="text" name="mail" size="30" value="'.($_SESSION['mail']!="" ? $_SESSION['mail'] : '').'" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="password">Password(da 3 a 8 caratteri):</label>
		<input type="password" name="password" size="30" /><sup>*</sup>
		</p>
		<p class="required text">
		<label for="conf_password">Conferma Password:</label>
		<input type="password" name="conf_password" size="30" /><sup>*</sup>
		<input type=hidden name=newsletter value=1>
		</p>
		<p class="text">
		<img id="imgCaptcha" width="200" height="40" src="captcha.php" alt="CAPTCHA" /> <a href="javascript:reloadCaptcha()"><img src="img/aggiorna.png" alt="" id="refresh" /></a>	
		<br clear="all" />
		<br clear="all" />
		<script>
		function caps(id){
			document.getElementById(id).value = document.getElementById(id).value.toUpperCase();
		}
		</script>
		<label for="captcha">Codice antispam:</label> <input name="captcha" type="text" id="captcha" onblur="caps(this.id)"><sup>*</sup>
		</p>
		<p><b>Dati per la spedizione ( compila se diverso dai dati anagrafici )</b></p>
		<p class="text">
		<label for="nome_s">Nome Cognome destinatario:</label>
		<input type="text" name="nome_s" size="30" value="'.($_SESSION['nome_s']!="" ? $_SESSION['nome_s'] : '').'" />
		</p>
		<p class="text">
		<label for="indirizzo_s">Indirizzo:</label>
		<input type="text" name="indirizzo_s" size="30" value="'.($_SESSION['indirizzo_s']!="" ? $_SESSION['indirizzo_s'] : '').'" />
		</p>
		<p class="text">
		<label for="localita_s">Localit&aacute;:</label>
		<input type="text" name="localita_s" size="30" value="'.($_SESSION['localita_s']!="" ? $_SESSION['localita_s'] : '').'" />
		</p>
		<p class="text">
		<label for="cap_s">CAP:</label>
		<input type="text" name="cap_s" size="30" value="'.($_SESSION['cap_s']!="" ? $_SESSION['cap_s'] : '').'" />
		</p>
		<p class="text">
		<label for="provincia">Provincia:</label>';
		//select provincia
		$sql = "SELECT provincia,sigla FROM province ORDER BY provincia;";
		$rsmenu = $conn->Execute($sql);
		$content .= $rsmenu->GetMenu("provincia_s",$_SESSION['provincia_s'],false);
		$rsmenu->Close();
		$content .= '
		</p>
		<p class="text">
		<label for="cellulare_s">Telefono cellulare:</label>
		<input type="text" name="cellulare_s" size="30" value="'.($_SESSION['cellulare_s']!="" ? $_SESSION['cellulare_s'] : '').'" />
		</p>
		<p>&nbsp;&nbsp;&nbsp;<input type=checkbox name=privacy value=1 checked>					
		&nbsp;
		&nbsp;Dichiaro di aver letto e accettato le <a href="javascript:;" onClick="MM_openBrWindow(\'foot-note_legali.html\',\'\',\'scrollbars=yes,width=300,height=300\')"><b>Note Legali</b></a> e l\'informativa sul diritto alla <a href="javascript:;" onClick="MM_openBrWindow(\'foot-privacy.html\',\'\',\'scrollbars=yes,width=300,height=300\')"><b>Privacy</b></a>
		</p>
		<p class="submit">
		<input type="hidden" name="op" value="send_subscribe" />
        <input type="submit" class="button" value="Conferma i Dati" onclick="return control_subscribe();" />
		</p>
		</fieldset>
		</form>';
		break;

	case "subscribe":
		if($newSession->getStatus()) {
		  header("Location:webproduct.php?op=profile");
		  die();
		} else {
			header("Location:webproduct.php?op=register");
			die();
		}
		break;

	case "send_subscribe":
		$nome = $_POST['nome'];
		$_SESSION['nome'] = $nome;
		$cognome = $_POST['cognome'];
		$_SESSION['cognome'] = $cognome;
		$ragione = $_POST['ragione'];
		$_SESSION['ragione'] = $ragione;
		$data = $_POST['data_nascita'];
		$_SESSION['data_nascita'] = $data;
		list($g,$m,$a) = explode("/",$data);
		$data = "$a-$m-$g";
		$cf = $_POST['cf'];
		$_SESSION['cf'] = $cf;
		$iva = $_POST['iva'];
		$_SESSION['iva'] = $iva;
		$indirizzo = $_POST['indirizzo'];
		$_SESSION['indirizzo'] = $indirizzo;
		$localita = $_POST['localita'];
		$_SESSION['localita'] = $localita;
		$provincia = $_POST['provincia'];
		$_SESSION['provincia'] = $provincia;
		$cap = $_POST['cap'];
		$_SESSION['cap'] = $cap;
		$nazione = $_POST['nazione'];
		$_SESSION['nazione'] = $nazione;
		$telefono = $_POST['telefono'];
		$_SESSION['telefono'] = $telefono;
		$cellulare = $_POST['cellulare'];
		$_SESSION['cellulare'] = $cellulare;
		$mail = $_POST['mail'];
		$_SESSION['mail'] = $mail;
		$password = trim($_POST['password']);
		$password_conf = trim($_POST['conf_password']);
		########################## diversa destinazione ####################################################
		$nome_s = $_POST['nome_s'];
		$_SESSION['nome_s'] = $nome_s;
		$indirizzo_s = $_POST['indirizzo_s'];
		$_SESSION['indirizzo_s'] = $indirizzo_s;
		$localita_s = $_POST['localita_s'];
		$_SESSION['localita_s'] = $localita_s;
		$provincia_s = $_POST['provincia_s'];
		$_SESSION['provincia_s'] = $provincia_s;
		$cellulare_s = $_POST['cellulare_s'];
		$_SESSION['cellulare_s'] = $cellulare_s;
		$cap_s = $_POST['cap_s'];
		$_SESSION['cap_s'] = $cap_s;
		####################################################################################################
		$newsletter = $_POST['newsletter'];
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Registrazione / Accesso</div>';
		$content = '<h1>Registrazione / Accesso</h1>';
		if($password != $password_conf)
		$content = printWebError("La password deve essere confermata correttamente","","Ritorna");
		else {
			$newUser = new webuser("",$nome,$cognome,$ragione,$data,$cf,$iva,$indirizzo,$localita,$cap,$provincia,$nazione,$telefono,$cellulare,$mail,$password,$indirizzo_s,$localita_s,$cap_s,$provincia_s,$nome_s,$cellulare_s);
			$error = $newUser->save();
			if($error == "0") {
				$_SESSION = Array();
				if($newsletter == "1")  {
					//salvo nel gruppo Webuser
					$contact = new contatti($mail,1);
					$errornews = $contact->save();
				} else
				$regtonewsletter = "";
				$content .= printWebMessage("Registrazione avvenuta con successo. Entro qualche minuto ti arriver&agrave; una e-mail all'indirizzo che hai inserito contenente username e password per accedere al servizio di acquisto on-line.","webproduct.php?op=register","Vai al login");
				//invio la mail di conferma
				$subject = "Conferma registrazione da Youtoys";
				$from = "MIME-Version: 1.0\nFrom: BSVillage <$adminmail>\nReply-To: $adminmail\nContent-type: text/html; charset=iso-8859-1\n";
				$message = "<HTML>
<HEAD> 
<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\"> 
<link href=\"http://www.youtoys.it/CSS/e-com.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD>
<body>
<table width=100% class=plain cellpadding=2>
								<tr>
								  <td width=100%>Gentile cliente, confermiamo la tua registrazione al servizio di acquisto on-line su www.youtoys.it<br>
								  Utilizzando username e password che ti forniamo potrai fare acquisti consultando direttamente il nostro catalogo on-line: il servizio ti permette di mantenere memorizzati gli ordini effettuati in precedenza, per gestire al meglio la tua attivit&agrave; se sei un'azienda, come promemoria se sei un privato.</td>
								</tr>
								<tr>
								 <td width=100%>Username: <b>$ragione</b><br>
								 Password: <b>$password</b></td>
								</tr>
								$regtonewsletter
								<tr>
								 <td width=100%>Clicca su questo indirizzo per fare il login<br>
								 <a class=plain href=\"http://www.youtoys.it\" target=_BLANK>Youtoys</a></td>
								</tr>
								<tr>
								 <td width=100% align=right class=plain2>Lo Staff di Business Shop</td>
								</tr>
								<tr>
								 <td width=100%></td>
								</tr>
					</table>
					</body>
					 </html>";
								$mail = trim($mail);
								mail($mail, $subject, $message, $from);
								############################## REINDIRIZZO AL CARRELLO SE PIENO ########################################################
				  	 $newSession = new websession($ragione,$password);
				  	 if(!is_null($newSession->uid))  {
				  	 	if($newSession->order->idwebuser == "0")  {
					     //articolo aggiunto nel carrello senza login
				  	 		$newSession->order->setUser($newSession->webuser->idwebuser);
					     Header("Location:webproduct.php?op=confirm");
					     die();
				  	 	}
				  	 	Header("Location:webproduct.php?op=confirm");
				  	 	die();
				  	 }
				  	 ##########################################################################################################################
			}
			else
			$content = printWebError($error,"","Ritorna");
		}

		break;

	case "risend_password":
		if($newSession->getStatus()) {
		  header("Location:webproduct.php?op=profile");
		  die();
		} else {
	  $navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Recupera Password</div>';
	  $content = '<h1>Recupera Password</h1>
	  <p><b>Inserisci l\'indirizzo e-mail che hai fornito al momento della registrazione ed entro pochi minuti riceverai una e-mail contenente una nuova password di accesso, che potrai cambiare una volta fatto il login.</b></p>
	  <form action=webproduct.php method=POST>
	  <fieldset>
	  <p class="text">
	  <label for="mail">Il tuo indirizzo e-mail:</label>
	  <input type=text name=mail size=20>
	  </p>
	  <p class="submit">
		<input type="hidden" name="op" value="send_password" />
        <input type="submit" class="button" value="Invia" />
		</p>
	  </fieldset>
	  </form>';
		}
		break;

	case "send_password":
		$mail = trim($_POST['mail']);
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Recupera Password</div>';
		$content = '<h1>Recupera Password</h1>';
		if (!eregi("^[a-z0-9][_\.a-z0-9-]+@([a-z0-9][0-9a-z-]+\.)+([a-z]{2,4})", $mail))  {
			$content .= printWebError("Hai inserito un'indirizzo e-mail non valido","","Ritorna");
		} else {
			$qry = "SELECT idwebuser FROM webuser WHERE mail='$mail';";
			$rs = $conn->Execute($qry);
			if($rs) {
				$idwebuser = $rs->Fields("idwebuser");
				$user_pass = new webuser($idwebuser);
				$error = $user_pass->send_password(1);
				$rs->Close();
			} else
			$error = "L'indirizzo e-mail che hai fornito non corrisponde a nessun utente registrato.";
			if($error == "0")
			$content .= printWebMessage("La nuova password &egrave; stata inviata con successo! Entro qualche minuto riceverai una e-mail all'indirizzo che hai inserito.","webproduct.php?op=register","Vai al login");
			else
			$content .= printWebError($error,"","Ritorna");
		}
		break;

	case "login":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Login</div>';
		$content = '<h1>Login</h1>';
		if($newSession->getStatus())
		Header("Location:webproduct.php?op=viewcart");
		else {
			$username = $_POST['username'];
			$password = $_POST['password'];
			$newSession = new websession($username,$password);
			if(!is_null($newSession->uid))  {
	   if($newSession->order->idwebuser == "0")  {
	   	//articolo aggiunto nel carrello senza login
	   	$newSession->order->setUser($newSession->webuser->idwebuser);
	   	header("Location:webproduct.php?op=confirm");
	   	die();
	   }
	   header("Location:webproduct.php?op=confirm");
	   die();
			} else
			$content .= printWebError("Username e password errati.","webproduct.php?op=register","Ritorna al login");
		}
		break;

	case "profile":
		if($newSession->getStatus())  {
			if($newSession->webuser->data!="0000-00-00")  {
				list($a,$m,$g) = explode("-",$newSession->webuser->data);
				$data = "$g/$m/$a";
			}  else
			$data = "";
			$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> My Home</div>';
			$content = '<h1>My Home</h1>';
			$content .= '<form name="subscribe" action="webproduct.php" method="POST" class="std">
			<div style="float:left;width:400px;">
					<fieldset class="account_creation">
					<h3>Riepilogo Dati Utente</h3>
					<p>( * campi obbligatori)</p>
					<p class="required text">
					<label for="nome">Nome:</label>
					<input type="text" name="nome" size=30 value="'.$newSession->webuser->nome.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="cognome">Cognome o Ragione Sociale:</label>
					<input type="text" name="cognome" size=30 value="'.$newSession->webuser->cognome.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="username">Username:</label>
					<input type="text" name="ragione" size=30 value="'.$newSession->webuser->ragione.'" /><sup>*</sup>
					</p>
					<p class="text">
					<label for="username">Data di nascita:</label>
					<input type=text size=10 name=data_nascita id=data onBlur="check_date(this)" value="'.$newSession->webuser->data.'">
					</p>
					<p class="text">
					<label for="cf">Codice fiscale(da indicare SEMPRE,anche se uguale a Partita IVA):</label>
					<input type="text" name="cf" size="30" value="'.$newSession->webuser->cf.'" />
					</p>
					<p class="text">
					<label for="pi">Partita iva:</label>
					<input type="text" name="pi" size="30" value="'.$newSession->webuser->pi.'" />
					</p>
					<p class="required text">
					<label for="indirizzo">Indirizzo:</label>
					<input type="text" name="indirizzo" size="30" value="'.$newSession->webuser->indirizzo.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="localita">Localit&aacute;:</label>
					<input type="text" name="localita" size="30" value="'.$newSession->webuser->localita.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="cap">CAP:</label>
					<input type="text" name="cap" size="30" value="'.$newSession->webuser->cap.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="provincia">Provincia:</label>';
			//select provincia
			$sql = "SELECT provincia,sigla FROM province ORDER BY provincia;";
			$rsmenu = $conn->Execute($sql);
			$content .= $rsmenu->GetMenu2("provincia",$newSession->webuser->provincia,false);
			$rsmenu->Close();
			$content .= '<sup>*</sup>
					</p>
					<p class="required text">
					<label for="nazione">Nazione:</label>';
			//select provincia
			$sql = "SELECT valore,id FROM nazioni ORDER BY valore;";
			$rsmenu = $conn->Execute($sql);
			$content .= $rsmenu->GetMenu2("nazione",$newSession->webuser->nazione,false);
			$rsmenu->Close();
			$content .= '<sup>*</sup>
					</p>
					<p class="required text">
					<label for="telefono">Telefono:</label>
					<input type="text" name="telefono" size="30" value="'.$newSession->webuser->telefono.'" /><sup>*</sup>
					</p>
					<p class="text">
					<label for="cellulare">Telefono cellulare:</label>
					<input type="text" name="cellulare" size="30" value="'.$newSession->webuser->cellulare.'" />
					</p>
					<p class="required text">
					<label for="mail">E-mail:</label>
					<input type="text" name="mail" size="30" value="'.$newSession->webuser->mail.'" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="password">Password(da 3 a 8 caratteri):</label>
					<input type="password" name="password" size="30" /><sup>*</sup>
					</p>
					<p class="required text">
					<label for="conf_password">Conferma Password:</label>
					<input type="password" name="conf_password" size="30" /><sup>*</sup>
					<input type=hidden name=newsletter value=1>
					</p>
					<p><b>Dati per la spedizione ( compila se diverso dai dati anagrafici )</b></p>
					<p class="text">
					<label for="nome_s">Nome Cognome destinatario:</label>
					<input type="text" name="nome_s" size="30" value="'.$newSession->webuser->nome_s.'" />
					</p>
					<p class="text">
					<label for="indirizzo_s">Indirizzo:</label>
					<input type="text" name="indirizzo_s" size="30" value="'.$newSession->webuser->indirizzo_s.'" />
					</p>
					<p class="text">
					<label for="localita_s">Localit&aacute;:</label>
					<input type="text" name="localita_s" size="30" value="'.$newSession->webuser->localita_s.'" />
					</p>
					<p class="text">
					<label for="cap_s">CAP:</label>
					<input type="text" name="cap_s" size="30" value="'.$newSession->webuser->cap_s.'" />
					</p>
					<p class="text">
					<label for="provincia">Provincia:</label>';
			//select provincia
			$sql = "SELECT provincia,sigla FROM province ORDER BY provincia;";
			$rsmenu = $conn->Execute($sql);
			$content .= $rsmenu->GetMenu2("provincia_s",$newSession->webuser->provincia_s,false);
			$rsmenu->Close();
			$content .= '
					</p>
					<p class="text">
					<label for="cellulare_s">Telefono cellulare:</label>
					<input type="text" name="cellulare_s" size="30" value="'.$newSession->webuser->cellulare_s.'" />
					</p>
					<p class="submit">
					<input type="hidden" name="op" value="update_webuser" />
			        <input type="submit" class="button" value="Salva Modifiche" onclick="return control_subscribe();" />
					</p>
					</fieldset>
			</div>
			</form>
			<div style="float:left;width:300px;margin-left:10px;">
			<h3 style="border-bottom: 2px solid #EEEEEE;padding: 14px 5px 5px 0;">I tuoi ordini precedenti</h3>';
			$order = $newSession->webuser->getOrderClosed();
			if($order)  {
				$content .= "<table width=300 class=plain cellpadding=2>
					 <tr>
					  <td width=70><b>Data</b></td>
					  <td width=143><b>Numero ordine</b></td>
					  <td width=70 align=center><b>Totale</b></td>
					  <td width=17>&nbsp;</td>
					 </tr>";
				foreach($order as $i => $n_order)  {
					//controllo il feedback
					$qry = "SELECT idfeed FROM feedback WHERE pid='$n_order->pid';";
					$rs = $conn->Execute($qry);
					if($rs)  {
						if($rs->RecordCount() > 0)  {
							$feed = "";
						} else {
							$feed = "<td align=center><a href=\"webproduct.php?op=sendFeed&pid=".$n_order->pid."\"><img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\"></a></td>";
						}
						$rs->Close();
					}
					list($a,$m,$g) = explode("-",$n_order->data);
					$data = "$g-$m-$a";
					$content .= "<tr bgcolor=#EAEAEA>
								<td>$data</td>
								<td align=center><a class=plain href=\"javascript:;\" onclick=\"javascript:window.open('pop_order.php?pid=".$n_order->pid."','','width=700,height=400,scrollbars=yes');\">BSV$n_order->pid</a></td>
								<td align=right>".number_format($n_order->totale,2,",",".")." &euro;</td>
								<td align=center>&nbsp;</td>
								".$feed."
					</tr>";
				}
				$content .= "</td>
						</tr>
						 </table>";
			}
				$content .= '</div>';
		} else {
			header("Location:webproduct.php?op=register");
			die();
		}
		break;

	case "update_webuser":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Aggiorna Dati</div>';
		if($newSession->getStatus())  {
			$nome = $_POST['nome'];
			$cognome = $_POST['cognome'];
			$ragione = $_POST['ragione'];
			$data = $_POST['data_nascita'];
			list($g,$m,$a) = explode("/",$data);
			$data = "$a-$m-$g";
			$cf = $_POST['cf'];
			$iva = $_POST['iva'];
			$indirizzo = $_POST['indirizzo'];
			$localita = $_POST['localita'];
			$provincia = $_POST['provincia'];
			$cap = $_POST['cap'];
			$nazione = $_POST['nazione'];
			$telefono = $_POST['telefono'];
			$cellulare = $_POST['cellulare'];
			$mail = $_POST['mail'];
			$password = trim($_POST['password']);
			$password_conf = trim($_POST['conf_password']);
			########################## diversa destinazione ####################################################
			$nome_s = $_POST['nome_s'];
			$indirizzo_s = $_POST['indirizzo_s'];
			$localita_s = $_POST['localita_s'];
			$provincia_s = $_POST['provincia_s'];
			$cellulare_s = $_POST['cellulare_s'];
			$cap_s = $_POST['cap_s'];
			####################################################################################################
			if($password != $password_conf)
	  $content = printWebError("La password deve essere confermata correttamente","","Ritorna");
	  else {
	  	$error = $newSession->webuser->update($nome,$cognome,$ragione,$data,$cf,$iva,$indirizzo,$localita,$cap,$provincia,$nazione,$telefono,$cellulare,$mail,$password,$indirizzo_s,$localita_s,$cap_s,$provincia_s,$nome_s,$cellulare_s);
	  	$content = printWebError($error,"webproduct.php?op=profile","Torna a My Home");
	  }
		} else {
			header("Location:index.php");
	  die();
	 }
	 break;

	case "viewcart":
		$newSession->cleanOrderExpired();
		//    if($newSession->getStatus()) {
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Carrello</div>';
		if(!is_null($newSession->order))  {
			$content = "<table width=100% height=100% id=cnt-dot2 border=0 cellpadding=0 cellspacing=0>
						<tr>
						 <td width=100% valign=top>";

			$content.= '<div class="navbar-cart"><img src="/images/01-blu.jpg"><img src="/images/02-grigio.jpg"><img src="/images/03-grigio.jpg"></div><br><br>';
			$content .= "<div id=\"cart\">".$newSession->order->viewCart()."</div>";
			$content .= "</td>
						</tr>
						 </table>";
		} else {
			$content = "<table width=100% class=plain cellpadding=2>
		 				<tr>
						 <td width=100% align=center><b>Il tuo carrello &egrave; vuoto.</b></td>
						</tr>
		 </table>";
		}
		/*
		 } else  {
		 Header("Location:webproduct.php?op=register");
		 die();
		 }
		 */
		break;

	case "addtoCart":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Carrello</div>';
		$newSession->cleanOrderExpired();
		$pid = $_COOKIE['pid'];
		$quantity = intval(trim($_POST['quantity']));
		$idarticolo = $_POST['idarticolo'];
		$correlati = $_POST['correlati'];
		$buono = trim($_POST['buono']);
		$variante = $_POST['variante'];
		if($variante=="") {
			$qry = "SELECT * FROM varianti WHERE idarticolo=$idarticolo ORDER BY id LIMIT 0,1;";
			$rs = $conn->Execute($qry);
			if($rs->RecordCount()>0) {
				$variante = $rs->Fields("nome").' '.$rs->Fields("codice").' '.$rs->Fields("descrizione");
				$rs->Close();
			}
		}
		$newArt = new articoli($idarticolo);
		$disp = intval($newArt->disp);
		//die($disp);
		if($disp > 0) {
			if($pid!="")  {
		  if(is_null($newSession->order))  {
		  	$newSession->order = new order($pid);
		  }
		  $error = $newSession->order->addArticolo($idarticolo,$quantity,$buono,$correlati,$variante);
			 if($error == "0") {
			 	$path = articoli::getPath($newArt->cid);
			 	list($cid3,$cid2,$cid1) = explode("-",$path);
			 	if($cid1 == "")  {
			 		$cid1 = $cid2;
			 		$cid2 = $cid3;
			 		$cid3 = "";
			 	} elseif($cid2 == "") {
			 		$cid1 = $cid3;
			 		$cid2 = "";
			 		$cid3 = "";
				 }
				 header("Location:webproduct.php?op=viewcart");
				 die();
			 }
			 else
			 $content = printWebError($error,"","Ritorna");
			} else {
				if($newSession->createOrder())  {
					$error = $newSession->order->addArticolo($idarticolo,$quantity,$buono,$correlati,$variante);
					if($error == "0") {
			   $newArt = new articoli($idarticolo);
			   $path = articoli::getPath($newArt->cid);
			   list($cid3,$cid2,$cid1) = explode("-",$path);
			   if($cid1 == "")  {
			   	$cid1 = $cid2;
			   	$cid2 = $cid3;
			   	$cid3 = "";
			   } elseif($cid2 == "") {
			   	$cid1 = $cid3;
				   $cid2 = "";
				   $cid3 = "";
			   }
			   header("Location:webproduct.php?op=viewcart");
			   die();
					} else
					$content = printWebError($error,"","Ritorna");
				} else {
					$content = printWebError("Articolo non caricato nel carrello. E' in corso l'aggiornamento del catalogo, riprova fra qualche minuto.","","Ritorna");
				}
			}
		} else
		$content = printWebError("L'articolo selezionato non &egrave; al momento disponibile.","","Ritorna");
		break;

	case "ajax_addtoCart":
		$newSession->cleanOrderExpired();
		$pid = $_COOKIE['pid'];
		$quantity = intval(trim($_POST['quantity']));
		$idarticolo = $_POST['idarticolo'];
		$newArt = new articoli($idarticolo);
		if($newArt->multiplo > 0) $quantity = $newArt->multiplo;
		$correlati = $_POST['correlati'];
		$buono = trim($_POST['buono']);
		$variante = $_POST['variante'];
		if($variante=="") {
			$qry = "SELECT * FROM varianti WHERE idarticolo=$idarticolo ORDER BY id LIMIT 0,1;";
			$rs = $conn->Execute($qry);
			if($rs->RecordCount()>0) {
				//$variante = $rs->Fields("nome").' '.$rs->Fields("codice").' '.$rs->Fields("descrizione");
				$variante = $rs->Fields("id");
				$rs->Close();
			}
		}
		$disp = intval($newArt->disp);
		if($disp > 0) {
			if($pid!="")  {
		  if(is_null($newSession->order))  {
		  	$newSession->order = new order($pid);
		  }
		  $error = $newSession->order->addArticolo($idarticolo,$quantity,$buono,$correlati,$variante);
			 if($error == "0") {
			 	$path = articoli::getPath($newArt->cid);
			 	list($cid3,$cid2,$cid1) = explode("-",$path);
			 	if($cid1 == "")  {
			 		$cid1 = $cid2;
			 		$cid2 = $cid3;
			 		$cid3 = "";
			 	} elseif($cid2 == "") {
			 		$cid1 = $cid3;
			 		$cid2 = "";
			 		$cid3 = "";
				 }
				 die();
			 }
			 else
			 die($error);
			} else {
				if($newSession->createOrder())  {
					$error = $newSession->order->addArticolo($idarticolo,$quantity,$buono,$correlati,$variante);
					if($error == "0") {
			   $newArt = new articoli($idarticolo);
			   $path = articoli::getPath($newArt->cid);
			   list($cid3,$cid2,$cid1) = explode("-",$path);
			   if($cid1 == "")  {
			   	$cid1 = $cid2;
			   	$cid2 = $cid3;
			   	$cid3 = "";
			   } elseif($cid2 == "") {
			   	$cid1 = $cid3;
				   $cid2 = "";
				   $cid3 = "";
			   }
			   die();
					} else
					die($error);
				} else {
					die("Articolo non caricato nel carrello. E' in corso l'aggiornamento del catalogo, riprova fra qualche minuto.");
				}
			}
		} else
		die("L'articolo selezionato non e' al momento disponibile.");
		break;

	case "updateQuantity":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Carrello</div>';
		$newSession->cleanOrderExpired();
		$quantita = $_POST['quantita'];
		$buono = trim($_POST['buono']);
		$servizi = trim($_POST['servizi']);
		if(!is_null($newSession->order)) {
			$flag = 0;
			foreach($quantita as $key => $num) {
				list($idarticolo,$codice) = explode("|",$key);
				$error = $newSession->order->updateQuantity($idarticolo,$num,$codice);
				  if($error != "0") {
				   $flag = 1;
				   $message = $error;
				  }
			}
			if($buono!="")
			$error = $newSession->order->updateDataAdd($buono,$servizi);
			if($servizi!='')
			$error = $newSession->order->updateServizi($servizi);
			if($error != "0")
			$flag = 1;
		}
		if($flag == 0)  {
			Header("Location:webproduct.php?op=viewcart");
			die();
		} else {
			$content = printWebError($message,'webproduct.php?op=viewcart','Ritorna al carrello');
		}
		break;

	case "deltoCart":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Carrello</div>';
		$idarticolo = $_GET['idarticolo'];
		$codice = $_GET['codice'];
		$newSession->cleanOrderExpired();
		if(!is_null($newSession->order)) {
			$newSession->order->delArticolo($idarticolo,$codice);
			Header("Location:webproduct.php?op=viewcart");
			die();
		}
		break;

	case "confirm":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Conferma Dati</div>';
		$newSession->cleanOrderExpired();
		$mode = $_GET['mode'];
		if($newSession->getStatus())  {
			if(!is_null($newSession->order))  {
				$buono = eregi_replace(".","",trim($_POST['buono']));
				$servizi = eregi_replace(".","",trim($_POST['servizi']));
				$content = "<table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
						<tr>
						 <td width=100% valign=top>";
					
				$content .= $newSession->confirm_POS();
				$content .= "</td>
						</tr>
						 </table>";
			} else {
	 	 header("Location:webproduct.php?op=viewcart");
	 	 die();
			}
		} else {
			header("Location:webproduct.php?op=register&mode=$mode");
			die();
	 }
	 break;

	case "close_order":
		if($newSession->getStatus())  {
			$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Chiusura Ordine</div>';
			$pagamento = $_POST['pagamento'];
			$note = $_POST['note'];
			if(!is_null($newSession->order))  {
				$newSession->order->changeTopay($pagamento);
				if($newSession->order->idwebuser != $newSession->webuser->idwebuser)
		  			$newSession->order->setUser($newSession->webuser->idwebuser);
				$articoli = $newSession->order->getArticoli();
				if(count($articoli) > 0)  {
					$totale = $newSession->order->getTotale($articoli);
					$spedizione = $newSession->order->getSpedizione($articoli);
					if($pagamento==3) {
						$contrassegno = ($totale+$newSession->order->servizi-$newSession->order->buono+$newSession->order->appuntamento+$newSession->order->consegna) / 100 * 3.5;
						$contrassegno = number_format($contrassegno,2,".","");
					} else
					$contrassegno = 0;
					$totaleOnly = $totale + $newSession->order->servizi+$newSession->order->consegna+$newSession->order->appuntamento;
					$totale = $totale + $spedizione + $newSession->order->servizi - $newSession->order->buono + $newSession->order->consegna+$newSession->order->appuntamento+$contrassegno;
					$peso = $newSession->order->getPeso($articoli);
					$error = $newSession->order->close($totale,$spedizione,$peso,$note,$articoli);
					$newSession->order->setHits($articoli);
					//$newSession->order->setDisp($articoli);
					$newSession->order->pagamento = $pagamento;
					if($error == "0")  {
						//mando le mail di conferma
						//utente
						$today = date("d-m-Y");
						$subject = "Conferma d'ordine da Youtoys";
						$from = "MIME-Version: 1.0\nFrom: BSVillage <$adminmail>\nReply-To: $adminmail\nContent-type: text/html; charset=iso-8859-1\n";
						$message = "<HTML>
	<HEAD> 
	<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\"> 
	<link href=\"http://www.youtoys.it/CSS/e-com.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD>
	<body>
	<table width=500 class=plain cellpadding=2>
									<tr>
									  <td width=500>Gentile cliente, confermiamo la chiusura e  registrazione dell'ordine d'acquisto BSV".$newSession->order->pid." da te fatto in data $today. Riportiamo di seguito i dati di spedizione e i dettagli articoli.</td>
									</tr>
									<tr>
									 <td width=500>
									 ".$newSession->mailUser($articoli)."
									 </td>
									</tr>";
						switch($pagamento) {
							case 1:
								//bonifico
								$message .= "<tr>
											<td>".$_CONFIG['mail_ordine_bonifico']."														
									</td>
										 </tr>";
						  break;

							case 2:
								//Ricarica poste Pay
								$message .= "<tr>
											<td>".$_CONFIG['mail_ordine_postepay']."
									</td>
										 </tr>";
						  break;

							case 3:
								//contrassegno
								$message .= "<tr>
											<td>".$_CONFIG['mail_ordine_contrassegno']."
									</td>
										 </tr>";
						  break;

							case 4:
								//carta di credito
								$importo = number_format($totale,2,".","");
								$codTrans = "BSV".$newSession->order->pid."";
								$mailTrans = $newSession->webuser->mail;
								$session_id = $newSession->uid;
								$message .= "<tr>
											<td>Hai scelto di pagare in con Carta di credito. Paga subito tramite carta di credito cliccando qui <br><a href=\"https://checkout.iwsmile.it/Pagamenti/?ACCOUNT=701001049&AMOUNT=".$importo."&ITEM_NAME=".$codTrans."&ITEM_NUMBER=".$session_id."&QUANTITY=1&URL_OK=&URL_BAD=&FLAG_ONLY_IWS=0&IMAGE_CODE=F6D12832580F985618B0BC22B8020016\"><img  src=\"https://www.iwsmile.it//images/puls_iwsmile_H.gif\" border=\"0\"></a>
											
									</td>
										 </tr>";					
						  break;

							case 5:

						  break;
						}
						$message .= "<tr>
						 <td width=100%>Ringraziamo di nuovo per la preferenza accordata.<br>
						 Restando a disposizione, porgiamo cordiali saluti.<br>
						 <b>youtoys.it</b>
						 </td>
						</tr>			
						</table>
						</body>
						 </html>";
						$mail = $newSession->webuser->mail;
						mail($mail, $subject, $message, $from);
						//mail amministrazione
						$subject = "Nuovo ordine BSV".$newSession->order->pid." da youtoys.it";
						$from = "MIME-Version: 1.0\nFrom: BSVillage <$adminmail>\nReply-To: $adminmail\nContent-type: text/html; charset=iso-8859-1\n";
						$message = "<HTML>
	<HEAD> 
	<META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\"> 
	<link href=\"http://www.youtoys.it/CSS/e-com.css\" rel=\"stylesheet\" type=\"text/css\"></HEAD>
	<body>
	<table width=500 class=plain cellpadding=2>
									<tr>
									  <td width=500>
									  E' arrivato un ordine di acquisto fatto in data $today. Riportiamo di seguito i dati di spedizione e i dettagli articoli.</td>
									</tr>
									<tr>
									 <td width=500 valign=top>
									 ".$newSession->mailAdmin($articoli)."
									 </td>
									</tr>
						</table>
						</body>
						 </html>";
						$mail = "info@bsvillage.com,simone@bsvillage.com,marcello.colli@gmail.com";
require_once("gestione/includes/class.phpmailer.php");
		$omail = new PHPMailer();
		$omail->IsSMTP();                    // attiva l'invio tramiteSMTP
		$omail->Mailer = "smtp";
		$omail->Host = "195.225.169.96";
		$omail->Username = "marcello@bsvillage.com";
		$omail->Password = "bsvillage001";
		$omail->From     = "marcello@bsvillage.com";
		$omail->FromName = "BSVILLAGE BUSINESS SHOP";
		$omail->SMTPAuth = true;
		$omail->IsHTML(true);
		//$omail->SMTPDebug = true;
		$omail->Subject  =  $subject;
		$omail->Body     =  $message;
		$omail->AddAddress("info@bsvillage.com");
		$omail->AddAddress("simone@bsvillage.com");
		$omail->AddAddress("marcello.colli@gmail.com");
		if($omail->Send()) {} else mail($mail, $subject, $message, $from);
						//mail($mail, $subject, $message, $from);
						$content = "<table width=100% height=100% id=cnt-dot2 border=0 cellpadding=0 cellspacing=0>
							<tr>
							 <td width=100% valign=top>";
							
						switch($pagamento)  {
							case 1:
								//bonifico
								$content .= "<table class=plain width=100% cellpadding=5>
								 <tr>
								  <td width=100%>
								   Il tuo ordine &egrave; stato inoltrato e chiuso. Fra qualche minuto riceverai una e-mail con il riepilogo dei dati relativi all'ordine fatto, valido come conferma e promemoria.
								  </td>
								 </tr>
								 <tr>
								  <td> 
								  Appena eseguito manda un fax al numero 0522 - 560484 con la ricevuta del versamento, in modo da velocizzare la procedura di spedizione. Grazie per aver scelto i nostri prodotti!
								  </td>
								 </tr>
								 <tr>
								  <td width=100% class=tit02 align=center>
									<b>
 <br>Business Shop Srl<br>
   ABI: 1005<br>
   CAB: 12800<br>
   Conto Corrente: 530<br>
   CIN: W<br>
   BANCA NAZIONALE DEL LAVORO SPA<br>
   IBAN CODE: IT68W0100512800000000000530<br>
   SWIFT: BNLIITRRREX</b><br><br>									
								  </td>
								 </tr>
								 <tr>
								  <td>&nbsp;</td>
								 </tr>
								 <tr>
								  <td>Nel momento in cui ti arriveranno i prodotti acquistati e si potr&agrave; considerare chiusa la transazione potrai lasciare un commento e un giudizio del nostro servizio nella tua <a class=plain href=webproduct.php?op=profile>HOME PAGE</a>, premendo il tasto &nbsp;<img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\">&nbsp; accanto al relativo ordine.</td>
								 </tr>
								</table>";
								break;

							case 2:
								//ricarica Poste Pay
								$content .= "<table class=plain width=100% cellpadding=5>
								 <tr>
								  <td width=100%>
								   Il tuo ordine &egrave; stato inoltrato e chiuso. Fra qualche minuto riceverai una e-mail con il riepilogo dei dati relativi all'ordine fatto, valido come conferma e promemoria.
								  </td>
								 </tr>
								 <tr>
								  <td width=100% class=tit02 align=center>
	La ricarica &egrave; istantanea, controllabile sul sito delle poste italiane. I pagamenti si effettuono on-line sul sito delle poste, o in qualsiasi ufficio postale comunicando l'importo totale da pagare e i dati di una delle 2 carte: <br><br>
							<b>4023 6004 4865 4659 intestata a Marcello Colli<br><br>
 							4023 6004 4865 4618 intestata a Marcello Colli</b><br><br> 
	Una volta effettuata la ricarica &egrave; IMPORTANTE inviarci una mail per notificarci l'avvenuto pagamento e indicarci l'ufficio postale da cui hai effettuato la ricarica o l'orario se hai effettuato la ricarica online							  </td>
								 </tr>
								 <tr>
								  <td>&nbsp;</td>
								 </tr>
								 <tr>
								  <td>Nel momento in cui ti arriveranno i prodotti acquistati e si potr&agrave; considerare chiusa la transazione potrai lasciare un commento e un giudizio del nostro servizio nella tua <a class=plain href=webproduct.php?op=profile>HOME PAGE</a>, premendo il tasto &nbsp;<img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\">&nbsp; accanto al relativo ordine.</td>
								 </tr>
								</table>";
								break;

							case 3:
								//contrassegno
								$content .= "<table class=plain width=100% cellpadding=5>
								 <tr>
								  <td width=100%>
								   Il tuo ordine &egrave; stato inoltrato e chiuso. Fra qualche minuto riceverai una e-mail con il riepilogo dei dati relativi all'ordine fatto, valido come conferma e promemoria.
								  </td>
								 </tr>
								 <tr>
								  <td width=100%>
									Prima di attivare la spedizione contatta direttamente l'operatore Business Shop per l'approvazione del contrassegno.</td>
								 </tr>
								 <tr>
								  <td>&nbsp;</td>
								 </tr>
								 <tr>
								  <td>Nel momento in cui ti arriveranno i prodotti acquistati e si potr&agrave; considerare chiusa la transazione potrai lasciare un commento e un giudizio del nostro servizio nella tua <a class=plain href=webproduct.php?op=profile>HOME PAGE</a>, premendo il tasto &nbsp;<img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\">&nbsp; accanto al relativo ordine.</td>
								 </tr>
								 <tr>
								  <td> 
								  Grazie per aver scelto i nostri prodotti!
								  </td>
								 </tr>
								</table>";
								break;
									
							case 4:
								//Carta di credito
								$importo = number_format($totale,2,".","");
								$codTrans = "BSV".$newSession->order->pid."";
								$mailTrans = $newSession->webuser->mail;
								$session_id = $newSession->uid;
								$pos = '<form action="https://checkout.iwsmile.it/Pagamenti/" method="post" target=_BLANK>
<input type="hidden" name="ACCOUNT" value="71700511">
<input type="hidden" name="AMOUNT" value="'.$importo.'">
<input type="hidden" name="ITEM_NAME" value="'.$codTrans.'">
<input type="hidden" name="ITEM_NUMBER" value="'.$newSession->order->pid.'">
<input type="hidden" name="QUANTITY" value="1">
<input type="hidden" name="URL_OK" value="">
<input type="hidden" name="URL_BAD" value="">
<input type="hidden" name="FLAG_ONLY_IWS" value="0">
<input type="hidden" name="IMAGE_CODE" value="F6D12832580F985618B0BC22B8020016">
<input type="image" src="https://www.iwsmile.it//images/puls_iwsmile_H.gif" border="0" name="submit" alt="Effettua i tuoi pagamenti con IWSMILE. Un sistema rapido, gratuito e sicuro.">
</form>';				
								$content .= "<table class=plain width=100% cellpadding=5>
								 <tr>
								  <td width=100%>
								   Il tuo ordine &egrave; stato inoltrato e chiuso. Fra qualche minuto riceverai una e-mail con il riepilogo dei dati relativi all'ordine fatto, valido come conferma e promemoria.
								  </td>
								 </tr>
								 <tr>
								  <td>&nbsp;</td>
								 </tr>
								 <tr>
								  <td>Nel momento in cui ti arriveranno i prodotti acquistati e si potr&agrave; considerare chiusa la transazione potrai lasciare un commento e un giudizio del nostro servizio nel tuo <a class=plain href=webproduct.php?op=profile>PROFILO</a>, premendo il tasto &nbsp;<img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\">&nbsp; accanto al relativo ordine.</td>
								 </tr>
								 <tr>
								  <td width=100%>
									Per effettuare il pagamento con carta di credito clicca sul pulsante qui sotto.</td>
								 </tr>
								 <tr>
								  <td align=center> 
									".$pos."
								  </td>
								 </tr>
								</table>";
								break;

							case 5:
								//Paypal
								$importo = number_format($totale,2,".","");
								$codTrans = "BSV".$newSession->order->pid."";
								$content .= "<table class=plain width=100% cellpadding=5>
								 <tr>
								  <td width=100%>
								   Il tuo ordine &egrave; stato inoltrato e chiuso, puoi procedere al pagamento con PayPal. Fra qualche minuto riceverai una e-mail con il riepilogo dei dati relativi all'ordine fatto, valido come conferma e promemoria.
								  </td>
								 </tr>
								 <tr>
								  <td width=100% align=center>
									<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=_BLANK>
	<input type=\"hidden\" name=\"cmd\" value=\"_xclick\">
	<input type=\"hidden\" name=\"business\" value=\"keopecolli@hotmail.com\">
	<input type=\"hidden\" name=\"item_name\" value=\"Ordine $codTrans\">
	<input type=\"hidden\" name=\"currency_code\" value=\"EUR\">
	<input type=\"hidden\" name=\"amount\" value=\"$importo\">
	<input type=\"image\" src=\"http://www.paypal.com/en_US/i/btn/x-click-but01.gif\" name=\"submit\" alt=\"Pagamento con PayPal. Facile e sicuro!\">
	</form></td>
								 </tr>
								 <tr>
								  <td>&nbsp;</td>
								 </tr>
								 <tr>
								  <td>Nel momento in cui ti arriveranno i prodotti acquistati e si potr&agrave; considerare chiusa la transazione potrai lasciare un commento e un giudizio del nostro servizio nel tuo <a class=plain href=webproduct.php?op=profile>PROFILO</a>, premendo il tasto &nbsp;<img src=\"../images/precedente.gif\" width=16 border=0 alt=\"Lascia un feedback\">&nbsp; accanto al relativo ordine.</td>
								 </tr>
								 <tr>
								  <td> 
								  Grazie per aver scelto i nostri prodotti!
								  </td>
								 </tr>
								</table>";				
								break;
						}
						$content .= "</td>
							</tr>
							 </table>";
					} else {
			   $content = printWebError("Servizio temporaneamente sospeso. Riprova fra qualche minuto..");
					}
					
					//tracciamento acquisti
					$trackTrans = '';
					$trackProd = '';
					foreach($articoli as $idarticolo => $qp)  {
						list($quantita,$prezzo,$idbuono) = explode("|",$qp);
						$articolo = new articoli($idarticolo);
						if($prezzo=="" || $prezzo==0)  {
							if($articolo->promozione == "y" && $articolo->prezzo2 != "0")
							$prezzo = $articolo->prezzo2;
							else
							$prezzo = $articolo->prezzo1;
						}
						$trackProd .= '
	_gaq.push([\'_addItem\',
	  "BSV'.$newSession->order->pid.'",
	  "'.$articolo->codice.'",
	  "'.$articolo->titolo1.'",
	  "'.$articolo->cid.'",
	  "'.number_format($prezzo, 2, '.', '').'",
	  "'.$quantita.'"
	]);';
					}
					
					$trackTrans = '
	_gaq.push([\'_addTrans\',
	  "BSV'.$newSession->order->pid.'",
	  "",
	  "'.number_format($totaleOnly, 2, '.', '').'",
	  "",
	  "'.$spedizione.'",
	  "",
	  "",
	  ""
	]);
	'.$trackProd.'
	_gaq.push([\'_trackTrans\']);'."\n";
					//-----------------------------
					
				} else {
		   $content = printWebError("Impossibile chiudere l'ordine! Non hai selezionato alcun prodotto.");
				}
			} else {
	 	 header("Location:webproduct.php?op=viewcart");
	 	 die();
			}
						
		} else {
			header("Location:index.php");
	  die();
		}
		
		break;

	case "deleteOrder":
		$pid = $_GET['pid'];
		if($newSession->getStatus())  {
	  $newOrder = new order($pid);
	  $error = $newOrder->delete();
	  if($error == "0")  {
	  	Header("Location:webproduct.php?op=profile");
	  	die();
	  } else {
	  	$content = printWebError($error,"","Ritorna");
	  }
		} else {
			Header("Location:index.php");
	  die();
	 }
	 break;

	case "paypal_closed":
		if($newSession->getStatus())  {
	  $content = "<table class=plain width=100% cellpadding=5>
							 <tr>
							  <td width=100%>
							   La transazione &egrave; stata chiusa con successo! Entro qualche minuto riceverai una e-mail di conferma all'indirizzo fornito al servizio PayPal.<br>
							   Grazie per la tua fiducia!
							  </td>
							 </tr>
					</table>";
		} else {
			Header("Location:index.php");
	  die();
	 }
	 break;

	case "logout":
		if($newSession->getStatus()) {
	  $newSession->logout();
		}
		Header("Location:index.php");
		die();
		break;

	case "search_web":
		//ricerca articoli
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Ricerca Articoli</div>';
		$search = $_GET['search'];
		if($search=="")
		$search = $_GET['search'];
		$min = $_GET['min'];
		$max = $_GET['max'];
		$page = $_GET['page'];
		$content = "<table width=100% height=100% id=cnt-dot2 border=0 cellpadding=0 cellspacing=0>
							<tr>
							 <td width=100% valign=top>";	
		$newSearch = new search($search);

		$content .= $newSearch->getSearch($min,$max,$page,$op);
		$content .= "</td>
						</tr>
						</table>";
		break;

	case "subscribe_news":
		$mail = $_POST['mailnews2'];
		//2--> gruppo Newsletter
		$contact = new contatti($mail,2);
		$error = $contact->save();
		$content = printWebError($error,"","Ritorna");
		break;
		
	case "remove_newsletter":
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Cancellati dalla Newsletter</div>';
	    $content = "<table width=510 class=plain cellpadding=3 cellspacing=0 style=\"border:1px solid #EAEAEA;\" align=center>
	  				<form action=webproduct.php method=POST>
					 <tr>
					  <td colspan=2 class=tit02>Inserisci il tuo indirizzo e-mail per rimuovere il tuo nome dalla nostra newsletter</td>
					 </tr>
					 <tr>
					  <td width=200 align=right>E-mail:</td>
					  <td width=350><input type=text name=mail size=20>&nbsp;&nbsp;<input type=submit value=INVIA><input type=hidden name=op value=doremove_newsletter></td>
					 </tr>
					</form>
	  				</table>";
    break;
  
	  case "doremove_newsletter":
	    $mail = $_POST['mail'];
		$new =  new contatti(trim($mail));
		$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Cancellati dalla Newsletter</div>';
		if($new->creation=="")
		  $text = '<p align="center">Indirizzo e-mail non trovato!</p>
		  <p align="center"><a href="javascript:history.go(-1);">Ritorna</a></p>';
		else {
		  $error = $new->delete();
		  $text = '<p align="center">Indirizzo e-mail eliminato con successo!</p>';
		}
		$content = "<table width=510 class=plain cellpadding=3 cellspacing=0 style=\"border:1px solid #EAEAEA;\" align=center>
					 <tr>
					  <td class=tit02>$text</td>
					 </tr>
	  				</table>";
	  break;

	case "sendFeed":
		if($newSession->getStatus())  {
	 	$pid = $_GET['pid'];
	 	$order = new order($pid);
	 	$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Feedback</div>';
	 	$content = "<table width=100% height=100% id=cnt-dot2 border=0 cellpadding=0 cellspacing=0>
							<tr>
							 <td width=100% valign=top>";

	 	$content .= "<table width=600 class=plain cellpadding=5 cellspacing=0>
					   <form name=formfeed action=webproduct.php method=POST>
						<tr>
						 <td class=tit02 colspan=2 align=center>Lascia il tuo commento sull'ordine numero BSV".$order->pid."</td>
						</tr>
						<tr>
						 <td colspan=2>&nbsp;</td>
						</tr>
						<tr>
						 <td width=100 align=right>Nome:</td>
						 <td><input type=text name=name value=".$newSession->webuser->ragione." size=50></td>
						</tr>
						<tr>
						 <td width=100 align=right valign=top>Giudizio:</td>
						 <td>
						 <table width=40>
						  <tr>
						   <td width=20><input type=radio name=voto value=negativo></td>
						   <td width=20><img src=\"../images/iconNeg_16x16.gif\" alt=Negativo></td>
						  </tr>
						  <tr> 
						   <td width=20><input type=radio name=voto value=neutro></td>
						   <td width=20><img src=\"../images/iconNeu_16x16.gif\" alt=Neutro></td>
						  </tr>
						  <tr> 
						   <td width=20><input type=radio name=voto value=positivo></td>
						   <td width=20><img src=\"../images/iconPos_16x16.gif\" alt=Positivo></td>
						  </tr> 
						 </table>
						</tr>
						<tr>
						 <td align=right valign=top>Commento:</td>
						 <td valign=top><textarea name=testo cols=100 rows=10></textarea></td>
						</tr>
						<tr>
						 <td colspan=2>&nbsp;<input type=hidden name=op value=addFeed>
						 <input type=hidden name=pid value=".$order->pid."></td>
						</tr>
						<tr>
						 <td colspan=2 align=center><input type=submit value=Invia></td>
						</tr>";
	 	$content .= "</form>
						</table>
					   </td>
						</tr>
						</table>";
		} else {
			Header("Location:index.php");
			die();
		}
		break;

	case "addFeed":
		if($newSession->getStatus())  {
			$pid = $_POST['pid'];
	 	$voto = $_POST['voto'];
	 	$testo = $_POST['testo'];
	 	$name = $_POST['name'];
	 	$order = new order($pid);
	 	$feed = new feedback("",$name,$pid,$voto,$testo);
	 	$error = $feed->save();
	 	$navbar = '<div class="breadcrumb"><a class="navbar" href="/index.php">Home</a> <span class="navigation-pipe">&gt;</span> Feedback</div>';
	 	$content = "<table width=100% height=100% id=cnt-dot2 border=0 cellpadding=0 cellspacing=0>
							<tr>
							 <td width=100% valign=top>";

	 	$content .= printWebError($error,"feedback.php","Guarda tutti i commenti");
	 	$content .= "</td>
						</tr>
						</table>";
		} else {
			header("Location:index.php");
			die();
		}
		break;

	case "upd_app":
		$error = $newSession->order->updateAppuntamento($_POST['app']);
		die($error);
		break;

	case "upd_cons":
		$error = $newSession->order->updateConsegna($_POST['cons']);
		die($error);
		break;

	case "getCart":
		die($newSession->order->viewCart());
		break;

	case "list_thumbs":
		$cid = $_POST['cid'];
		$order = $_POST['order'];
		$min = $_POST['min'];
		if($min=="") $min=0;
		$max = $_POST['max'];
		if($max=="") $max = $num_per_page;
		$page = $_POST['page'];
		if($page=="") $page = 1;
		$produttore = $_POST['produttore'];
		if($produttore=="") $produttore = $_GET['produttore'];
		$filtro = Array();
		foreach ($_POST as $name=>$value) {
			if($value!="") {
			  $pos = strpos($name,"iltro");
			  if(!$pos===false) {
			  	$arr = explode("-",$name);
			  	$filtro[$arr[1]] = $value;
			  }
			}
		}
		$start = $_POST['start'];
		$end = $_POST['end'];
		list($cid3,$cid2,$cid1) = explode("-",category::getParent($cid,$cid));
		if($cid1 == "")  {
			$cid1 = $cid2;
			$cid2 = $cid3;
			$cid3 = "";
		}
		$elencoTab = $_POST['tab'];
		die(listArticoli::getThumb($cid,$order,$min,$max,$page,$op,$filtro,$start,$end,$produttore,$elencoTab));
		break;

	case "list_articoli":
		$cid = $_POST['cid'];
		$order = $_POST['order'];
		$newList = new listArticoli($cid,"plain",$lang,$order);
		die($newList->show(0,20,1,$op));
		break;

	case "ajax_getMenu":
		$cid1 = $_POST['cid1'];
		$cid2 = $_POST['cid2'];
		die(category::getMenu($cid1,$cid2));
		break;

	case "get_manuale":
		$mail = $_POST['mail_manuale'];
		$nome = $_POST['nome_manuale'];
		if($mail!="") {
			$contact = new contatti($mail,2);
	  $error = $contact->save();
	  articoli::getManuale($mail,$nome);
	  $content = printWebError("Riceverai via e-mail il nostro manuale per la manutenzione della tua piscina","index.php","Ritorna");
		} else
		$content = printWebError("Hai inserito una e-mail non valida","index.php","Ritorna");
		break;

	case "menuSearch":
		die(category::getSearchMenu());
		break;
		
	case "promo":
		$url = $_GET['url'];
		$content = banner::showPromo($url);
		break;
		
	case "promozioni":
		$content = banner::showPromozioni();
		break;

	default:
		//$cid = $_GET['cid'];
		###############################################################################################
		$link = $_GET['link'];
		$cat = $_GET['cat'];
		$min = $_GET['min'];
		$max = $_GET['max'];
		$page = $_GET['page'];
		$order = $_GET['order'];
		$idarticolo = $_GET['id'];
		$produttore = $_POST['produttore'];
		if($produttore=="") $produttore = $_GET['produttore'];
		if($produttore=="") $produttore = Array();
		foreach ($_GET as $name=>$value) {
			if($value!="") {
			  $pos = strpos($name,"iltro");
			  if(!$pos===false) {
			  	$arr = explode("-",$name);
			  	$filtro[$arr[1]] = $value;
			  }
			}
		}
		$start = $_GET['start'];
		$end = $_GET['end'];
		if($link!="") {
			$id = category::getId($link);
			if($id > 0) {
				list($cid3,$cid2,$cid1) = explode("-",category::getParent($id,$id));
				if($cid1 == "")  {
					$cid1 = $cid2;
					$cid2 = $cid3;
					$cid3 = "";
				} else if($cat=="") {
					$newCat = new category($cid2);
					header("HTTP/1.1 301 Moved Permanently");
					header("Location: http://youtoys.bsvillage.com/".$newCat->hidden."/$link/");
					die();
				}
			} else {
				$id = category::checkOldUrl($link);
				if($id > 0) {
					list($cid3,$cid2,$cid1) = explode("-",category::getParent($id,$id));
					if($cid1 == "")  {
						$cid1 = $cid2;
						$cid2 = $cid3;
						$newCat = new category($cid2);
						header("HTTP/1.1 301 Moved Permanently");
						header("Location: http://youtoys.bsvillage.com/".$newCat->hidden."/");
						die();
					} else {
						$newCat2 = new category($cid2);
						$newCat3 = new category($cid3);
						header("HTTP/1.1 301 Moved Permanently");
						header("Location: http://youtoys.bsvillage.com/".$newCat2->hidden."/".$newCat3->hidden."/");
						die();
					}
				} else {
					header("HTTP/1.1 301 Moved Permanently");
					header("Location: http://youtoys.bsvillage.com");
					die();
				}
			}
		}
		if($_GET['cid1']!="") {
			$cid1 = $_GET['cid1'];
			$cid = $cid1;
		}
		if($_GET['cid2']!="")
		$cid2 = $_GET['cid2'];
		if($_GET['cid3']!="")
		$cid3 = $_GET['cid3'];
		################################################################################################
		if($order=="")
		$order = "prezzo2 ASC";
		//$content = '<div class="box-content">';	
		if($cid1 != "" && $cid2 != "")  {
			$navbar = articoli::getNavbar($cid1,$cid2);

			$newCat = new category($cid2);
			############ indicizzazione ##############################################################
			if($newCat->tagtitle!="") {
				$newCat->tagtitle = str_replace("| youtoys.it","",$newCat->tagtitle);
				if(!strpos($newCat->tagtitle,"| youtoys.it") === false)
				$tagtitle = $newCat->tagtitle;
				else
				$tagtitle = $newCat->tagtitle." | youtoys.it";
			} else
			$tagtitle = $newCat->titolo." | youtoys.it";
			if($newCat->tagkey!="")
			$tagkey = $newCat->tagkey;
			else
			$tagkey = $newCat->titolo;
			if($newCat->tagdesc!="")
			$tagdesc = $newCat->tagdesc;
			else
			$tagdesc = $newCat->titolo." | youtoys.it";;
			$metatitle = $newCat->metatitle;
			$metakey = $newCat->metakey;
			$metadesc = $newCat->metadesc;
			$hidden = $newCat->hidden;
			###############################################################################################
			$content .= "<h1>$newCat->titolo</h1>";
			if (!empty($newCat->desc)) $content .= "<div style=\"padding:10px;\">".$newCat->desc."</div>";    
			$newList = new listArticoli($cid2,"plain",$lang,$order);
			$newCats = new listCat($cid2);
			if(is_a($newList->result,"ADORecordSet") && $newList->result->RecordCount() > 0 && $newCats->result->RecordCount()==0) { 	
			  $content .= '<ul id="product_list" class="clear">'.$newList->show($min,$max,$page,$op).'</ul>';
			} else {
				$content .= $newCats->show($cid1,$filtro,$start,$end,$produttore);
			}
			//$content .= "</div>";
			if (in_array($cid2,array('54','653','504'))) {
				$content .= form_aweber_coperture('1', $newCat->titolo);
			}
		}  elseif($cid2 != "" && $cid3 == "")  {
			$navbar = articoli::getNavbar($cid1,$cid2,$cid3);

			$newCat = new category($cid2);
			############ indicizzazione ##############################################################
			if($newCat->tagtitle!="") {
				$newCat->tagtitle = str_replace("| youtoys.it","",$newCat->tagtitle);
				if(!strpos($newCat->tagtitle,"| youtoys.it") === false)
				$tagtitle = $newCat->tagtitle;
				else
				$tagtitle = $newCat->tagtitle." | youtoys.it";
			} else
			$tagtitle = $newCat->titolo." | youtoys.it";
			if($newCat->tagkey!="")
			$tagkey = $newCat->tagkey;
			else
			$tagkey = $newCat->titolo;
			if($newCat->tagdesc!="")
			$tagdesc = $newCat->tagdesc;
			else
			$tagdesc = $newCat->titolo." | youtoys.it";;
			$metatitle = $newCat->metatitle;
			$metakey = $newCat->metakey;
			$metadesc = $newCat->metadesc;
			$hidden = $newCat->hidden;
			###############################################################################################
			$content .= "<h1>$newCat->titolo</h1>";
			if (!empty($newCat->desc)) $content .= "<div style=\"padding:10px;\">".$newCat->desc."</div>";     
			$newList = new listArticoli($cid2,"plain",$lang,$order);
			if(is_a($newList->result,"ADORecordSet") && $newList->result->RecordCount() > 0)
			$content .= '<ul id="product_list" class="clear">'.$newList->show($min,$max,$page,$op).'</ul>';
		}
		if($idarticolo!="")  {
			$newArt = new articoli($idarticolo);
			$permalinkurl = $_GET['permalink'];
			if($cid1=="" && $cid2=="" && $cid3=="")  {
				if($newArt->giardino=="1" && $newArt->isCorrelato() > 0) {
					$cid = 2;
					$cid1 = $cid;
					$cid2 = $newArt->isCorrelato();
				} else {
					$cat = new category($newArt->cid);
					list($cid3,$cid2,$cid1) = explode("-",category::getParent($cat->cid,$cat->cid));
					if($cid1 == "")  {
				  $cid1 = $cid2;
				  $cid2 = $cid3;
				  $cid3 = "";
					}
					$cid = $cid1;
				}
			}

			$navbar = articoli::getNavbar($cid1,$cid2,$cid3);
			############ indicizzazione ##############################################################
			$newArt->tagtitle = str_replace("| youtoys.it","",$newArt->tagtitle);
			$tagtitle = $newArt->tagtitle;
			if(strpos($tagtitle,"| youtoys.it") === false)
				$tagtitle = $tagtitle." | youtoys.it";
			$tagkey = $newArt->tagkey;
			$tagdesc = str_replace("<br>","",$newArt->tagdesc);
			$metatitle = $newArt->metatitle;
			$metakey = $newArt->metakey;
			$metadesc = str_replace("<br>","",$newArt->metadesc);
			$hidden = $newArt->hidden;
			###############################################################################################
			if($newArt->attivo == 'y')
			$content .= $newArt->getDetail();
			//$content .= "</div>";
		} elseif($cid3!="") {
			//elenco articoli
			$navbar = articoli::getNavbar($cid1,$cid2,$cid3);	
			$newCat = new category($cid3);
			############ indicizzazione ##############################################################
			if($newCat->tagtitle!="") {
				$newCat->tagtitle = str_replace("| youtoys.it","",$newCat->tagtitle);
				if(!strpos($newCat->tagtitle,"| youtoys.it") === false)
				$tagtitle = $newCat->tagtitle;
				else
				$tagtitle = $newCat->tagtitle." | youtoys.it";
			} else
			$tagtitle = $newCat->titolo." | youtoys.it";
			if($newCat->tagkey!="")
			$tagkey = $newCat->tagkey;
			else
			$tagkey = $newCat->titolo;
			if($newCat->tagdesc!="")
			$tagdesc = $newCat->tagdesc;
			else
			$tagdesc = $newCat->titolo." | youtoys.it";;
			$metatitle = $newCat->metatitle;
			$metakey = $newCat->metakey;
			$metadesc = $newCat->metadesc;
			$hidden = $newCat->hidden;
			###############################################################################################
			$content = "<h1>$newCat->titolo</h1>";
			if (!empty($newCat->desc)) $content .= "<div style=\"padding:10px;\">".$newCat->desc."</div>";   
			$newList = new listArticoli($cid3,"plain",$lang,$order);
			$content .= '<ul id="product_list" class="clear">'.$newList->show($min,$max,$page,$op).'</ul>';
			//$content .= "</div>";
			if (in_array($cid2,array('54','653','504'))) {
				$content .= form_aweber_coperture('1', $newCat->titolo);
			}
		}
		break;
}

function form_aweber_coperture($num, $tit) {
	return '
	<div class="contenitore-form-aweber">'."\n".
		'<form method="post" class="af-form-wrapper" action="http://www.youtoys.it'.$_SERVER['REQUEST_URI'].'" onsubmit="validazioneForm(\'awf-nome'.$num.'\', \'awf-email'.$num.'\', \'awf-privacy'.$num.'\'); return returnVal;">
		<div style="display: none;">
		<input name="meta_web_form_id" value="1063592716" type="hidden" />
		<input name="meta_split_id" type="hidden" />
		<input name="listname" value="coperture-pisci" type="hidden" />
		<input name="redirect" value="http://www.youtoys.it/piscine/thanks.php?ref=http://www.youtoys.it'.$_SERVER['REQUEST_URI'].'" id="redirect_142950e74e1fb7ae53c92f09d0e5358d" type="hidden" />
		<input name="meta_redirect_onlist" value="http://www.youtoys.it/piscine/thanks.php?ref=http://www.youtoys.it'.str_replace("&", "-amp;-",$_SERVER['REQUEST_URI']).'" type="hidden" />
		<input name="meta_adtracking" value="FormNew2011" type="hidden" /> <input name="meta_message" value="1" type="hidden" />
		<input name="meta_required" value="name,email,custom Telefono,custom Privacy" type="hidden" />
		<input name="meta_tooltip" type="hidden" />
		<input type="hidden" name="url_prodotto" value="http://www.youtoys.it'.str_replace("&", "&amp;",$_SERVER['REQUEST_URI']).'">
		<input type="hidden" name="nome_prodotto" value="'.$tit.'">
		</div>
		<div id="af-form-366544877" class="af-form">
		<div id="af-header-366544877" class="af-header">
		<div class="bodyText">
		<div>
		<div>
		<div style="text-align: center;"><span style="font-size: 18pt; font-weight: bold; color: #cc0000;"><img src="http://www.coperture-piscina.com/wp-content/themes/redbel/images/bulletV.gif" style="width: 31px; height: 33px;" alt="" />Si, voglio ricevere subito un\'Offerta!</span>
		<p style="text-align: center; font-size: 14px;"><span style="font-family: Arial;">Scrivi il tuo <span style="font-weight: bold;">nome</span> (non serve il cognome), il tuo <span style="font-weight: bold;">telefono</span>, la tua <span style="font-weight: bold;">email</span>.<br /> 
		  Se Desideri un Preventivo su Misura Compila gli altri campi, ma non e obbligatorio</span><span class="MsoNormal"><span style="font-family: Verdana;">.</span></span></p>
		<p style="text-align: center; font-size: 16px;"><span style="font-size: 16px; font-family: Verdana;">"<span style="font-weight: bold;">Si, inviatemi un\'offerta!</span>"</span></p>    
		</div>
		</div>
		</div>
		</div>
		</div>
		<div id="af-body-366544877" class="af-body af-standards">
		<div class="af-element"><label class="previewLabel" for="awf-nome'.$num.'">Nome * </label>
		<div class="af-textWrap"><input id="awf-nome'.$num.'" name="name" class="text" tabindex="'.$num.'600" type="text" /></div>
		<div class="af-clear"></div>
		</div>
		<div class="af-element"><label class="previewLabel" for="awf-email'.$num.'">Email * </label>
		<div class="af-textWrap"><input class="text" id="awf-email'.$num.'" name="from" tabindex="'.$num.'601" type="text" /></div>
		<div class="af-clear"></div>
		</div>
		<div class="af-element"><label class="previewLabel" for="awf-telefono'.$num.'">Telefono * </label>
		<div class="af-textWrap"><input id="awf-telefono'.$num.'" class="text" name="custom Telefono" tabindex="'.$num.'602" type="text" /></div>
		<div class="af-clear"></div>
		</div>
		<div class="af-element"><div><label class="previewLabel" style="width:100%">Che tipo di copertura desideri?</label></div></div>
		<div class="af-clear"></div>
		<div class="af-element af-element-checkbox">
		<div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751787" class="checkbox"  name="custom Copertura Invernale" tabindex="'.$num.'603" /> 
		<label class="choice" for="awf_field-15751787">Copertura Invernale</label>
		</div><div class="af-clear"></div></div><div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751788" class="checkbox"  name="custom Copertura invernale di sicurezza" tabindex="'.$num.'604" /> 
		<label class="choice" for="awf_field-15751788">Copertura invernale di sicurezza</label>
		</div><div class="af-clear"></div></div><div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751789" class="checkbox"  name="custom Copertura Isotermica" tabindex="'.$num.'605" /> 
		<label class="choice" for="awf_field-15751789">Copertura Isotermica</label>
		</div><div class="af-clear"></div></div><div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751790" class="checkbox"  name="custom Copertura a tapparella" tabindex="'.$num.'606" /> 
		<label class="choice" for="awf_field-15751790">Copertura a tapparella</label>
		</div><div class="af-clear"></div></div><div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751791" class="checkbox"  name="custom Copertura telescopica" tabindex="'.$num.'607" /> 
		<label class="choice" for="awf_field-15751791">Copertura telescopica</label>
		</div><div class="af-clear"></div></div>
		<div class="af-element"><div><label class="previewLabel" style="width:100%">Forma della copertura?</label></div></div>
		<div class="af-clear"></div>
		<div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751792" class="checkbox"  name="custom Rettangolare" tabindex="'.$num.'608" /> 
		<label class="choice" for="awf_field-15751792">Rettangolare</label>
		</div><div class="af-clear"></div></div>
		<div class="af-element af-element-checkbox"><div class="af-checkWrap">
		<input type="checkbox" value="yes" id="awf_field-15751793" class="checkbox"  name="custom Sagomata su misura" tabindex="'.$num.'609" /> 
		<label class="choice" for="awf_field-15751793">Sagomata su misura</label>
		</div><div class="af-clear"></div></div>
		<div class="af-element"><div><label class="previewLabel" for="awf_field-160789900">Tipologia di piscina:</label><div class="choiceList choiceList-radio-stacked">
		<div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-160789900" name="custom Tipologia di piscina"  value="Piscina Interrata" tabindex="'.$num.'609" /> 
		<label class="choice" for="awf_field-160789900">Piscina Interrata</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-160789901" name="custom Tipologia di piscina"  value="Piscina Seminterrata" tabindex="'.$num.'609" /> 
		<label class="choice" for="awf_field-160789901">Piscina Seminterrata</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-160789902" name="custom Tipologia di piscina"  value="Piscina Fuori Terra" tabindex="'.$num.'609" /> 
		<label class="choice" for="awf_field-160789902">Piscina Fuori Terra</label>
		<div class="af-clear"></div></div></div></div><div class="af-clear"></div></div>
		<div class="af-element"><div><label class="previewLabel" for="awf_field-157517940">Forma della Piscina</label><div class="choiceList choiceList-radio-stacked">
		<div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517940" name="custom Forma della Piscina"  value="Rettangolare" tabindex="'.$num.'610" /> 
		<label class="choice" for="awf_field-157517940">Rettangolare</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517941" name="custom Forma della Piscina"  value="Rettangolare con scala romana" tabindex="'.$num.'611" /> 
		<label class="choice" for="awf_field-157517941">Rettangolare con scala romana</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517942" name="custom Forma della Piscina"  value="Circolare" tabindex="'.$num.'612" /> 
		<label class="choice" for="awf_field-157517942">Circolare</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517943" name="custom Forma della Piscina"  value="Libera" tabindex="'.$num.'613" /> 
		<label class="choice" for="awf_field-157517943">Libera</label>
		<div class="af-clear"></div></div></div></div><div class="af-clear"></div></div><div class="af-element"><div><label class="previewLabel" for="awf_field-157517950">Filtrazione della piscina?</label><div class="choiceList choiceList-radio-stacked">
		<div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517950" name="custom Filtrazione della piscina"  value="a skimmer" tabindex="'.$num.'614" /> 
		<label class="choice" for="awf_field-157517950">a skimmer</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517951" name="custom Filtrazione della piscina"  value="a sfioro" tabindex="'.$num.'615" /> 
		<label class="choice" for="awf_field-157517951">a sfioro</label>
		<div class="af-clear"></div></div></div></div><div class="af-clear"></div></div><div class="af-element"><div><label class="previewLabel" for="awf_field-157517960">Cosa ce attorno alla piscina?</label><div class="choiceList choiceList-radio-stacked">
		<div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517960" name="custom Cosa c e attorno alla tua piscina"  value="Terreno" tabindex="'.$num.'616" /> 
		<label class="choice" for="awf_field-157517960">Terreno</label>
		<div class="af-clear"></div></div><div class="af-element-radio multiChoice">
		<input class="radio" type="radio" id="awf_field-157517961" name="custom Cosa c e attorno alla tua piscina"  value="Pavimentazione" tabindex="'.$num.'617" /> 
		<label class="choice" for="awf_field-157517961">Pavimentazione</label>
		<div class="af-clear"></div></div></div></div><div class="af-clear"></div></div><div class="af-element">
		<label class="previewLabel" for="awf_field-15751797">Lunghezza e Larghezza specchio dell\'acqua piscina (comprensiva della scala romana se presente)</label>
		<div class="af-textWrap"><input type="text" id="awf_field-15751797" class="text" name="custom Lunghezza e Larghezza massima della piscina" value=""  tabindex="'.$num.'618" /></div>
		<div class="af-clear"></div></div>
		<div class="af-element">
		<label class="previewLabel" for="awf_field-15782648">Raggio della scala Romana (compilare solo se presente)</label>
		<div class="af-textWrap"><input type="text" id="awf_field-15782648" class="text" name="custom Raggio della scala Romana" value=""  tabindex="'.$num.'618" /></div>
		<div class="af-clear"></div></div>
		<div class="af-element">
		<label class="previewLabel" for="awf_field-15751798">Larghezza del bordo perimetrale (cm)</label>
		<div class="af-textWrap"><input type="text" id="awf_field-15751798" class="text" name="custom Larghezza del bordo" value="" tabindex="'.$num.'619" /></div>
		<div class="af-clear"></div></div><div class="af-element">
		<label class="previewLabel" for="awf_field-15751799">Ulteriori comunicazioni</label>
		<div class="af-textWrap"><textarea rows="" cols="" name="custom Ulteriori comunicazioni" id="awf_field-15751799"  tabindex="'.$num.'620" style="height:60px"></textarea></div><div class="af-clear"></div></div>
		<div class="af-element af-element-checkbox">
		<div class="af-checkWrap"><input value="yes" id="awf-privacy'.$num.'" class="checkbox" name="custom Privacy" tabindex="'.$num.'621" type="checkbox" /> <label class="choice" for="awf-privacy'.$num.'">Informativa sulla <a href="http://www.youtoys.it/webpage.php?idpage=33" target="popup" onclick="wopen(\'http://www.youtoys.it/webpage.php?idpage=33&popup\', \'popup\', 850, 550); return false;">Privacy</a></label></div>
		<div class="af-clear"></div>
		</div>
		<div class="af-element buttonContainer"><input name="submit" class="submit" value="Si, Inviatemi un Offerta!" tabindex="'.$num.'622" type="submit" />
		<div class="af-clear"></div>
		</div>
		</div>
		<div id="af-footer-366544877" class="af-footer">
		<div class="bodyText">
			<p><span style="font-size: 14px;">* N.B. per coperture sagomate, inviare disegno e piantina della piscina possibilmente in formato DWG. Puoi inviarla direttamente a <span style="font-weight: bold;"><script type="text/javascript">document.write("<a href=\'javascript:noSpam(\"info\",\"youtoys.it\",\"Invio file da Coperture Piscina\")\'>info@youtoys.it</a>");</script></span></p>
		</div>
		</div>
		</div>
		<div style="display: none;"><img src="http://forms.aweber.com/form/displays.htm?id=jAxszKycTOyMbA==" /></div>
		</form>'.
	'</div>'."\n";
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xml:lang="it" xmlns="http://www.w3.org/1999/xhtml"><head>
<? include("includes/header.php") ?>
</head>
<body>
<!--[if lt IE 7]><div style='clear:both;height:59px;padding:0 15px 0 15px;position:relative;z-index:10000;text-align:center;'><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx?ocid=ie6_countdown_bannercode"><img src="http://www.theie6countdown.com/images/upgrade.jpg" border="0" height="42" width="820" alt="You are using an outdated browser. For a faster, safer browsing experience, upgrade for free today." /></a></div><![endif]-->
<div id="wrapper1">
<div id="wrapper2">
<div id="wrapper3">
	<!-- Header -->
<? include("includes/top.php")?>
	<div id="columns">
<!-- Left -->
<? include("includes/left.php")?>
<!-- Center -->
<div id="center_column" class="center_column">
<?=$navbar?>
<?=$content?>
</div>
		<div class="clearblock"></div>
	</div>
</div>
<!-- Footer -->
	<div id="footer_wrapper">
<? include("includes/footer.php")?>
	</div>
</div>
</div>
	</body></html>